﻿//创建时间: 2010-12-15
//创建作者: 李 城
//功能说明: cms外部页面访问基类 动态访问列表页
//最后修改: 2010-12-15
using System;
using System.Collections.Generic;
using System.Text;
using System.Collections;
using TRPOP.CMS.Business;
using TRPOP.CMS.Model;
using System.Web;

using TRPOP.Config;
using TRPOP.Common;

namespace TRPOP.CMS.Web.ExtraBus
{
    /// <summary>
    /// 动态访问  列表页
    /// </summary>
    public class Page_Load_list : BasePage
    {

        int m_intPageindex = RequestHelper.RequestInt("page");
        int m_intNodeId = RequestHelper.RequestInt("nodeid");

        protected override void OnPreInit(EventArgs e)
        {
            if (!IsPostBack && ExecutePageURLCahche())
            {
                return;
            }
            base.OnPreInit(e);
        }

        protected override void OnInit(EventArgs e)
        {

            SubPageInit();

            if (ViewState["nodeid"] != null)
            {
                m_intNodeId = ViewState["nodeid"].ToString().ToInt();
                if (ViewState["page"] != null)
                {
                    m_intPageindex = ViewState["page"].ToString().ToInt();
                }
            }

            if (m_intNodeId <= 0)
            {
                Base_Config.NotFound(base.Page, "page request nothing ");
                return;
            }
            else if (m_intPageindex <= 0)
            {
                m_intPageindex = 1;
            }
            
            Load_list();

            //base.OnInit(e);

        }
        /// <summary>
        /// 动态访问列表页
        /// </summary>
        public void Load_list()
        {
            TRPOP.CMS.Model.NodeInfo oNodeInfo = new TRPOP.CMS.Model.NodeInfo();
            oNodeInfo = (new NodeManage()).GetInfoById(m_intNodeId);
            if (oNodeInfo == null)
            {
                Base_Config.NotFound(base.Page,"栏目为空");
            }
            object obj = TRPOP.CMS.Publish.PublishAccess.GetOneNodeIndexPage(oNodeInfo, m_intPageindex);
            if (obj is string)
            {
                Response.Clear();
                Response.ClearHeaders();
                Response.ClearContent();
                Response.Write(obj.ToString());
                if (base.mBlnEnableCache)
                    base.mICache.Save(base.mCacheKey, obj.ToString(), BasePage.mCacheSeconds);
                Response.End();
            }
            else
                Base_Config.NotFound(base.Page,"信息解析不正确，信息不存在或信息模板有问题");
        }
    }
}
